Skip to content

Handle vscode.git activation failure in VS Code forks#603

Open
mukuliitkgp wants to merge 1 commit into
github:mainfrom
mukuliitkgp:fix/vscode-fork-git-extension-compatibility
Open

Handle vscode.git activation failure in VS Code forks#603
mukuliitkgp wants to merge 1 commit into
github:mainfrom
mukuliitkgp:fix/vscode-fork-git-extension-compatibility

Conversation

@mukuliitkgp

Copy link
Copy Markdown

Summary

The extension crashes in VS Code forks (Kiro, Cursor, etc.) where cross-extension activation of built-in extensions is restricted. This PR adds graceful error handling and a fallback so the extension works in all VS Code-compatible editors.

Problem

getGitExtension() in src/git/repository.ts calls gitExtension.activate() without error handling. In VS Code forks, this throws "Cannot activate foreign extension" and crashes the entire extension. Users see "Unable to connect to the GitHub API" with no way to use the extension.

What changed

  • Wrapped gitExtension.activate() in try/catch — activation failures are now logged and the function returns undefined gracefully instead of crashing
  • Added a fallback in getGitHubUrls() — when vscode.git is unavailable, the extension reads .git/config directly from workspace folders to discover GitHub repository remotes
  • Extracted parseGitRemoteUrl into its own module — keeps the parsing logic testable without pulling in vscode dependencies

Testing

  • Added 9 unit tests for .git/config parsing covering SSH URLs, HTTPS URLs, enterprise URLs, remote name matching, and fallback behavior
  • All existing tests continue to pass (39/39 total)
  • Manually tested in Kiro IDE (VS Code fork) — extension now discovers repos correctly
  • No regression in standard VS Code — the try/catch only activates when activate() throws

Related Issues

Fixes #582
Relates to #555, #590

The extension crashes in VS Code forks like Kiro and Cursor because activating the built-in vscode.git extension throws an unhandled error. This wraps the activation call in a try/catch and adds a fallback that reads .git/config directly to discover remotes when the git extension is unavailable.
@mukuliitkgp mukuliitkgp requested a review from a team as a code owner June 24, 2026 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to connect to the GitHub API

1 participant